The FOR Statement
The FOR statement in VectorScript executes the same script section a specified number of times. This value is held within a control variable which is evaluated by the FOR statement to determine whether execution of the script section should continue.
The general syntax for FOR statements is:
 
FOR <control variable> := <initial value> [TO | DOWNTO] <limit value>
The initial and final values, or limit values, of the control variable are set in the FOR statement. These values may be INTEGER, LONGINT, or CHAR values, and can be either constants or values derived from an expression. The value of the control variable is modified and evaluated by the FOR statement prior to each pass through the script section controlled by the statement.
FOR statements come in two varieties: the FOR-TO statement, and the FOR-DOWNTO statement. In the FOR-TO statement, the value of the control variable is incremented (increased) by one on each pass through the section controlled by the statement. For example:
FOR i:=1 TO 10 DO Message('Pass ',i,' through FOR loop.');
In the FOR-TO statement, the control variable i will be incremented by one and evaluated on each pass before the Message() function call is executed.
In a FOR-DOWNTO statement, the value of the control variable is decremented (decreased) by a value of one on each pass until the limit value is reached. For example:
 
In the FOR statement, the value of i is decremented on each pass until it reaches the limit value of one. Also note that a compound statement can be used to execute any number of other statements within the FOR statement structure.
The following cautions should be observed when working with FOR statements:
*
Do not try to change the value of the control variable from within the FOR statement; doing so can lead to unpredictable results.
*
*
If the limit values are equal, the FOR statement will execute its controlled statement exactly once.
*
If the limit values are reversed, the FOR statement will be skipped.

Statements : Repetition Statements : The FOR Statement

Nemetschek NA
Phone: 410.290.5114
Fax: 410.290.8050